#include "win2_user_face.h"

lv_obj_t *win2;

lv_obj_t *win2_mment;

lv_obj_t  *win2_oder;

lv_obj_t  *win2_feedback;

lv_obj_t *btn1;
lv_obj_t *btn2;
lv_obj_t *btn3;

int flag = 0;
// static lv_style_t style;

static void btn_event_cb(lv_event_t * e)
{
    lv_obj_t* target = lv_event_get_target(e) ;
    if(target==btn1)
    {
        lv_obj_del(win2);
        flag=1;
        win3_mment();
    }
    if(target==btn2)
    {
        
    }
    if(target==btn3)
    {
        
    }
}

void win3_user_face(void)
{
    
    // lv_font_t * font = lv_freetype_font_create(
    //     "/home/gec/samba_share/001__lv_port_linux_ubuntu_sdl/my_project/Data/simkai.ttf", // 字体文件路径
    //     LV_FREETYPE_FONT_RENDER_MODE_BITMAP, 24, LV_FREETYPE_FONT_STYLE_NORMAL);

    // if(!font) {
    //     LV_LOG_ERROR("freetype font create failed.");
    //     return;
    // }
    // if(flag == 0) {
    //     /*Create style with the new font*/
    //     lv_style_init(&style);
    //     lv_style_set_text_font(&style, font);
    //     lv_style_set_text_align(&style, LV_TEXT_ALIGN_CENTER);
    // }
    win2 = lv_obj_create(lv_scr_act());
    lv_obj_set_size(win2, 800, 480);
    lv_obj_set_style_pad_all(win2, 0, 0);
    lv_obj_set_style_bg_color(win2, lv_color_hex(0x000FF0), 0);
    lv_obj_clear_flag(win2, LV_OBJ_FLAG_SCROLLABLE);
    lv_obj_set_align(win2, LV_ALIGN_CENTER);

    lv_obj_t* img = lv_img_create(win2);
    LV_IMG_DECLARE(beijing);
    lv_img_set_src(img, &beijing);
    lv_obj_set_align(img, LV_ALIGN_CENTER);

    win2_mment = lv_obj_create(win2);
    lv_obj_set_size(win2_mment, 250, 350);
    lv_obj_set_style_opa(win2_mment, 150, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_align(win2_mment, LV_ALIGN_CENTER,0,0);
    lv_obj_t* img_user2 = lv_img_create(win2_mment);
    LV_IMG_DECLARE(user2);
    lv_img_set_src(img_user2, &user2);
    lv_obj_set_align(img_user2, LV_ALIGN_TOP_MID);
    btn1 = lv_btn_create(win2_mment);
    lv_obj_set_size(btn1, 200, 50);
    lv_obj_align(btn1, LV_ALIGN_BOTTOM_MID,0,-20);
    lv_obj_t* label = lv_label_create(btn1);
    //lv_obj_add_style(label, &style, 0);
    lv_label_set_text(label, "commodityManagement");
    lv_obj_align(label, LV_ALIGN_CENTER,0,0);
    lv_obj_add_event_cb(btn1, btn_event_cb, LV_EVENT_CLICKED, NULL);
    
    win2_oder = lv_obj_create(win2);
    lv_obj_set_size(win2_oder, 250, 350);
    lv_obj_set_style_opa(win2_oder , 150, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_align(win2_oder, LV_ALIGN_CENTER,260,0);
    lv_obj_t* img_user3 = lv_img_create(win2_oder);
    LV_IMG_DECLARE(user3);
    lv_img_set_src(img_user3, &user3);
    lv_obj_set_align(img_user3, LV_ALIGN_TOP_MID);
    btn2 = lv_btn_create(win2_oder);
    lv_obj_set_size(btn2, 200, 50);
    lv_obj_align(btn2, LV_ALIGN_BOTTOM_MID,0,-20);
    lv_obj_t* label2 = lv_label_create(btn2);
    //lv_obj_add_style(label2, &style, 0);
    lv_label_set_text(label2, "feedback");
    lv_obj_align(label2, LV_ALIGN_CENTER,0,0);
    lv_obj_add_event_cb(btn2, btn_event_cb, LV_EVENT_CLICKED, NULL);



    win2_feedback = lv_obj_create(win2);
    lv_obj_set_size(win2_feedback, 250, 350);
    lv_obj_set_style_opa(win2_feedback, 150, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_align(win2_feedback, LV_ALIGN_CENTER,-260,0);
    lv_obj_t* img_user1 = lv_img_create(win2_feedback);
    LV_IMG_DECLARE(user1);
    lv_img_set_src(img_user1, &user1);
    lv_obj_set_align(img_user1, LV_ALIGN_TOP_MID);
    btn3 = lv_btn_create(win2_feedback);
    lv_obj_set_size(btn3, 200, 50);
    lv_obj_align(btn3, LV_ALIGN_BOTTOM_MID,0,-20);
    lv_obj_t* label3 = lv_label_create(btn3);
    //lv_obj_add_style(label3, &style, 0);
    lv_label_set_text(label3, "orderManagement");
    lv_obj_align(label3, LV_ALIGN_CENTER,0,0);
    lv_obj_add_event_cb(btn3, btn_event_cb, LV_EVENT_CLICKED, NULL);

}
